<template>
	<view class="wrapForm">
		<view class="bgLine flex jst-between pL25 pR25">
			<block v-if="!isSm">
				<view class="w60">
					<view class="font26 bold">实名认证</view>
					<view class="font14 u-9 mT5">
						仅确保您的信息真实有效，信息 将严格保密
					</view>
				</view>
				<image class="rzImg" :src="resources.rzImg" mode=""></image>
			</block>
		</view>
		<view class="wrapFormBody pL15 pR15 pT15 rzBox">
			<view class="font18">个人基本信息</view>
			<u-form :label-width="200" :label-style="{'font-size':'30rpx'}" class="xf-wrap-form" ref="dataForm"
				:rules="rules" :model="formData">

				<u-form-item label="真实姓名" :label-position="'top'" prop="realName">
					<view class="w100 flex alg-center jst-between">
						<view class="w70"><u-input :disabled="isSm" class="t-right" placeholder="请输入真实姓名"
								v-model="formData.realName" /></view>
						<u-icon v-if="!isSm" size="24" name="arrow-right" color="#8d8d8d"></u-icon>
					</view>
				</u-form-item>
				<u-form-item label="身份证号" :label-position="'top'" prop="idCard">
					<view class="w100 flex alg-center jst-between">
						<view class="w70"><u-input class="t-right" placeholder="请输入身份证号" v-model="formData.idCard" />
						</view>
						<u-icon v-if="!isSm" size="24" name="arrow-right" color="#8d8d8d"></u-icon>
					</view>
				</u-form-item>

				<view v-if="isSm">
					<view class="rzCardBox flex alg-center jst-between pL15 pR5">
						<view class="flex alg-center">
							<image class="imgRzCard" :src="resources.sfCard" mode=""></image>
							<text class="mL10 font15">身份证认证</text>
						</view>
						<u-icon name="arrow-right" size="24" color="#8d8d8d"></u-icon>
					</view>
					<view class="rzCardBox flex alg-center jst-between pL15 pR5">
						<view class="flex alg-center">
							<image class="imgRzCard" :src="resources.face" mode=""></image>
							<text class="mL10 font15">人脸识别</text>
						</view>
						<u-icon name="arrow-right" size="24" color="#8d8d8d"></u-icon>
					</view>

				</view>
			</u-form>
		</view>
		<view class="flex jst-center bottomW" v-if="!isSm">
			<view class="pointer rightNowPay u-f font15 t-center" @click="saveMyInfo">
				确定
			</view>
		</view>
	</view>
</template>

<script>
	import {
		authenticationPerson
	} from "@/api/userInterface/user.js"
	export default {
		data() {
			return {
				isSm: false,
				formData: {
					realName: '',
					idCard: ''
				},
				rules: {
					realName: [{
						required: true,
						message: '请输入真实姓名',
						trigger: ['change', 'blur'],
					}],
					idCard: [{
						required: true,
						message: '请输入身份证号',
						trigger: ['change', 'blur'],
					}, {
						rule: /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X|x)$/,
						msg: '请正确输入您的身份证号码15-18位'
					}]
				}
			}
		},
		onReady() {
			this.$refs.dataForm.setRules(this.rules);
		},
		methods: {
			saveMyInfo() {
				this.$refs.dataForm.validate(valid => {
					if (valid) {
						authenticationPerson(this.formData)
					} else {
						console.log('验证失败');
					}
				});
			}
		}
	}
</script>
<style lang="scss">
	page {

		/* #ifdef MP-WEIXIN */
		height: 100%;
		/* #endif */
		background-color: #fff;
	}
</style>
<style lang="scss" scoped>
	.wrapForm {
		.rzCardBox {

			height: 128rpx;
			background: #F8F8F8;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			margin-top: 60rpx;

			&:last-child {
				margin-top: 30rpx;
			}

			.imgRzCard {
				width: 40rpx;
				height: 32rpx;
			}
		}

		height: 100%;

		.wrapFormBody {
			margin-top: -30rpx;
			border-radius: 40rpx 40rpx 0 0;
			background: #fff;
		}

		.uni-forms-item {
			align-items: center !important;
		}

		.uni-input-placeholder {
			// text-align: right !important;
			color: #BDBDBD !important;
		}
	}

	.bgLine {
		background-color: #EBF0FF;
		width: 100%;
		// height: 60rpx;
		padding: 30rpx 40rpx;

		.rzImg {
			width: 168rpx;
			height: 192rpx;
		}
	}

	.bottomW {
		position: fixed;
		bottom: 40rpx;
		width: 100%;
		left: 0;
	}

	.rightNowPay {
		width: 670rpx;
		height: 100rpx;
		line-height: 100rpx;
		background: #3291F8;
		border-radius: 30rpx;

	}
</style>